<#import "spring.ftl" as spring />
<#setting number_format="0.##">
<#setting locale="en_US">
<script type="text/javascript">
	var baseweb = '${baseweb}';
</script>
<script type="text/javascript"
        src="${baseweb}/module/decorator/js/listProductsSetup.js">
</script>
<div id="tableResult">
<#assign currentPage = command.paging.pageNumber/>
  <#assign nextPage = currentPage + 1/>
  <#assign prevPage = currentPage - 1/>
  <#assign totalPages = command.paging.totalPageNumber - 1/>
<#if result?has_content>
  <table width='100%' border='0' class='results bottomMargin' id='userList'
      cellpadding='0' cellspacing='0'>
      <col width="8%" />
      <col width="15%" />
      <col width="25%" />
      <col width="12%" />
      <col width="9%" />
      <col width="6%" />
      <col width="5%" />
      <col width="5%" />
      <col width="5%" />
      <col width="10%" />
      <thead>
        <tr>
        <th><@spring.message "product.list.code"/></th>
        <th><@spring.message "product.list.name"/></th>
        <th><@spring.message "product.list.description"/></th>
        <th><@spring.message "product.list.category"/></th>
        <th><@spring.message "product.list.brand"/></th>
        <th><@spring.message "product.list.measure"/></th>
        <th><@spring.message "product.list.price"/></th>
        <th><@spring.message "product.list.desk.price"/></th>
        <th><@spring.message "product.list.stock"/></th>
        <th><@spring.message "product.list.actions"/></th>
        </tr>
      </thead>
      <tbody>
        <#list result as product>
          <#assign styleRow = "">
          <#if !product.active>
            <#assign styleRow = "style='text-decoration: line-through;'">
          </#if>
          <tr ${styleRow}>
            <td>${product.code}</td>
            <td>${product.name}</td>
            <td>${product.description!""}</td>
            <td>${product.category}</td>
            <td>${product.brand}</td>
            <td>${product.measureType}</td>
            <td>${product.rawPrice}</td>
            <td>${product.deskPrice}</td>
            <td>${product.stock}</td>
            <td>
              <a href="editProduct.do?productId=${product.id}" style="text-decoration: underline!important"><@spring.message "product.list.edit" /></a>
              <a href="#" onclick="javascript: deleteProduct('deleteProduct.do?productId=${product.id}', ${currentPage});" style="text-decoration: underline!important">
              <#if product.active>
				<@spring.message "product.list.delete" /></a>
              <#else>
				<@spring.message "product.list.activate" /></a>
              </#if>
            </td>
          </tr>
        </#list>
    </tbody>
  </table>
</#if>

  <#if totalPages &gt; 0 && currentPage &gt; 0>
     <a href="${baseweb}/module/product/products.do?page=${prevPage}">
          &lt;&lt;
     </a>
  </#if>
  Page ${currentPage + 1} of ${totalPages+1}
  <#if totalPages &gt; 0 && currentPage &lt; totalPages>
     <a href="${baseweb}/module/product/products.do?page=${nextPage}">
          &gt;&gt;
     </a>
  </#if>
</div>